package com.rop.znyx.activity.api;

import com.rop.znyx.activity.service.ActivityInfoService;
import com.rop.znyx.common.result.Result;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA
 * User: Rop
 * Date: 2023/7/21
 * Time: 11:19
 * Description:
 */

@RestController
@RequestMapping("api/activity/inner/")
@RequiredArgsConstructor
public class ActivityApiController {

    private final ActivityInfoService activityInfoService;

    /**
     * 根据skuId列表获取促销信息
     */
    @PostMapping("findActivity")
    public Result<Map<Long, List<String>>> findActivity(@RequestBody List<Long> skuIdList) {
        return activityInfoService.findActivity(skuIdList);
    }

    @ApiOperation(value = "根据skuId获取促销与优惠券信息")
    @GetMapping("findActivityAndCoupon/{skuId}/{userId}")
    public Result<Map<String, Object>> findActivityAndCoupon(@PathVariable Long skuId, @PathVariable("userId") Long userId) {
        return Result.ok(activityInfoService.findActivityAndCoupon(skuId, userId));
    }
}
